package com.dragon.www.haier.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.dragon.www.haier.R;

/**
 * Created by liqp on 2016/10/27.
 */
public class TitleView extends RelativeLayout{

    private ImageView img_back;
    private ImageView img_set;
    private ImageView img_title;
    private TextView txt_title;

    public TitleView(Context context) {
        super(context);
        initView();
    }

    public TitleView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView();
    }

    public TitleView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
    }


    private void initView() {

        View view = View.inflate(getContext(), R.layout.title, this);
        img_back = (ImageView) view.findViewById(R.id.img_back);
        img_set = (ImageView) view.findViewById(R.id.img_set);
        txt_title = (TextView) view.findViewById(R.id.txt_title);
        img_title = (ImageView) view.findViewById(R.id.img_title);

    }

    public void setTitle(String title) {
        txt_title.setText(title);
        img_title.setVisibility(GONE);
        txt_title.setVisibility(VISIBLE);
    }

    public void setTextSetAction(View.OnClickListener listener){
        img_set.setOnClickListener(listener);
    }

    public void setTextBackAction(View.OnClickListener listener){
        img_back.setOnClickListener(listener);
    }

    public void setBackCancel(){
        img_back.setVisibility(View.GONE);
    }
}
